FROM debian:bookworm-slim

# 1. 强制写一份干净的国内源
RUN rm -f /etc/apt/sources.list.d/* && \
	echo 'deb http://mirrors.ustc.edu.cn/debian bookworm main contrib non-free' > /etc/apt/sources.list && \
	echo 'deb http://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free' >> /etc/apt/sources.list && \
	echo 'deb http://mirrors.ustc.edu.cn/debian bookworm-updates main contrib non-free' >> /etc/apt/sources.list

# 2. 更新 + 安装所有编译依赖（一条 RUN，避免缓存问题）
RUN apt-get update && \
	DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
	gcc g++ make cmake \
	libpcre3-dev zlib1g-dev libssl-dev \
	zip unzip && \
	apt-get clean && rm -rf /var/lib/apt/lists/*

# 3. 接下来保持你原来的逻辑
ADD nginx-rtmp-module-master.zip nginx-vod-module-1.33.zip nginx-1.21.6.zip /usr/local/src/
WORKDIR /usr/local/src

RUN unzip nginx-1.21.6.zip \
	&& unzip nginx-rtmp-module-master.zip \
	&& unzip nginx-vod-module-1.33.zip \
	&& cd nginx-1.21.6 \
	&& chmod +x ./configure \
	&& ./configure --with-http_ssl_module --with-file-aio --with-threads --add-module=../nginx-rtmp-module-master --add-module=../nginx-vod-module-1.33 \
	&& make \
	&& make install \
	&& mv ../nginx-rtmp-module-master /usr/local/nginx/nginx-rtmp-module \
	&& cd /usr/local/nginx/ \
	&& \cp ./nginx-rtmp-module/test/nginx.conf ./conf/nginx.conf \
	&& sed -i "s@/path/to/nginx-rtmp-module/@nginx-rtmp-module@g" ./conf/nginx.conf

WORKDIR /

VOLUME /usr/local/nginx/conf

EXPOSE 1935 8080

CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]